function Pages(current, pageSize) {
    //查询参数
    this.params = {};
    this.param = {};
    //分页参数
    this._data = {};
    this._data.current = current;
    this._data.pageSize = pageSize;
}

//分页方法
Pages.prototype.createPages = function(fn) {
    var _data = this._data;
    if (_data.pageCount) {
        $('#js_pagebar').show();
        $('#js_pagebar').unbind(); //必须先解绑.再绑定.否则各种错误!
        $('#js_pagebar').createPage({
            pageCount: _data.pageCount,
            current: _data.current,
            backFn: function(p) {
                _data.current = p;
                fn && fn(); //queryList(_data); 重复调用自己，已达到分页切换的目的
            }
        });
    } else {
        $("#js_pagebar").hide();
    }
}

Pages.prototype.queryList = function(_roleListUrl, fn) {
    this.params.pagesize = this._data.pageSize;
    this.params.startrow = (this._data.current - 1) * this._data.pageSize;
    this.params.param = this.param;
    var _data = this._data;
    var params = this.params;
    ajaxResponse({
        dAsync: false,
        params: params,
        surl: _roleListUrl,
        sFn: function(data) {
            var total = data.content.total;
            if (total) {
                if (total % _data.pageSize) {
                    _data.pageCount = parseInt(total / _data.pageSize) + 1;
                } else {
                    _data.pageCount = total / _data.pageSize;
                }
            } else {
                _data.pageCount = 0;
            }
            fn && fn(data); //parseOneData(data.content.rows, 'roleTableTpl', '.oneTplID');
            ///return _data;
        },
        selectOther: ".rolePermission"
    });
}

//渲染一层模板数据list方法
function parseOneData(oneData, oneTplID, selector) {
    var len = oneData.length;
    $(selector).empty();
    for (var i = 0; i < len; i++) {
        var jsonData = oneData[i];
        jsonData._num = i + 1;
        var oneTplNode = $(template(oneTplID, jsonData));
        $(selector).append(oneTplNode);
    }
}